package com.example.comitclx1.mapper;

import com.example.comitclx1.pojo.Emp;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface EmpMapper {
    /**
     * 查询
     * @return
     */
    List<Emp> list(String name, Short gender, LocalDate begin, LocalDate end);
    /**
     * 删除操作
     * @param ids
     */
    void delete(List<Integer> ids);
    @Insert("insert into emp(username, name, gender, image, job, entrydate, dept_id, create_time, update_time)\n" +
            "values (#{username},#{name},#{gender},#{image},#{job},#{entrydate},#{deptId},#{createTime},#{updateTime})")
    void inset(Emp emp);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Select("select * from emp where id=#{id}")
    Emp getById(Integer id);

    /**
     * 修改数据
     * @param emp
     */
    void update(Emp emp);

    /**
     * 登录
     * @param emp
     * @return
     */
    @Select("select * from emp where username=#{username} and password=#{password}")
    Emp getByUsernameAndPassword(Emp emp);

    /**
     * 根据部门id删除员工数据
     * @param id
     */
    @Delete("delete from emp where dept_id=#{id}")
    void getByDeptId(Integer id);
}

/**
 * 分页查询
 */
   /* @Select("select count(*) from emp")
    long count();
    @Select("select * from emp limit #{begin},#{pageSize}")
    List<Emp> pagesum(Integer begin, Integer pageSize);
*/